/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package PropertyRental.war.servlets;

import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author Sébastien
 */
public class UpdatePropertyAction extends Action {
    public UpdatePropertyAction(String success, String fail) {
        super(success,fail);
    }

    @Override
    public String perform(HttpServletRequest req) {
         try {
            if (req.getParameter("update") != null) {
                Long id = Long.parseLong(req.getParameter("id"));
                String type = req.getParameter("type");
                String adress = req.getParameter("adress");
                int numberBedroom = Integer.parseInt(req.getParameter("numberBedroom"));
                int numberBathroom = Integer.parseInt(req.getParameter("numberBathroom"));
                int numberOtherRoom = Integer.parseInt(req.getParameter("numberOtherRoom"));
                double rent = Double.parseDouble(req.getParameter("rent"));
                String location = req.getParameter("location");

                if (propertyEJB.updateProperty(id, type, adress, numberBedroom, numberBathroom, numberOtherRoom, rent, location)) {
                    return this.getSuccesspage();
                }
            }
        } catch (Exception ex) {
        }
        return this.getFailpage();
    }

}
